package com.yingxin.yxerp.module.print.vo.resp;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yingxin.yx.framework.commons.activiti.ApprovalStatusHelper;
import com.yingxin.yx.framework.commons.constant.CommonConst;
import com.yingxin.yx.framework.commons.enums.BusinessType;
import com.yingxin.yx.framework.commons.helper.DateHelper;
import com.yingxin.yx.framework.commons.vo.CommonRespVo;
import com.yingxin.yx.framework.render.core.RenderColumn;
import com.yingxin.yx.framework.render.core.RenderForm;
import com.yingxin.yxerp.module.common.BusinessTypeHelper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

/**
 * 打印申请
 * @author fanchao
 * @since 2022-03-21
 */

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "PrintApplyRespVo对象", description = "打印申请")
@RenderForm(name = "打印申请")
public class PrintApplyRespVo extends CommonRespVo {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "打印申请id")
    private String id;

    @RenderColumn(name = "申请单号", sort = 1, isToDoList = true )
    private String applyNo;

    @RenderColumn(name = "申请人", sort = 2)
    private String applicantName;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    protected Date createTime;

    @RenderColumn(name = "申请时间", sort = 3, isToDoList = true )
    private String createTimeFormat;

    public String getCreateTimeFormat(){
        return DateHelper.dateFormat( createTime, DateHelper.YYYYMMDDHHMMSS );
    }

    @ApiModelProperty(value = "业务 id")
    private String businessId;

    @RenderColumn(name = "业务单号", sort = 4, isToDoList = true )
    private String businessNo;

    @ApiModelProperty(value = "业务类型")
    private String businessType;

    @RenderColumn(name = "业务类型", sort = 5, isToDoList = true )
    private String businessTypeName;

    public String getBusinessTypeName() {
        return BusinessTypeHelper.getName(businessType);
    }

    @ApiModelProperty(value = "审核状态")
    private String approvalStatus;

    @RenderColumn(name = "审核状态", sort = 6)
    public String getApprovalStatusName() {
        return ApprovalStatusHelper.getName(approvalStatus);
    }

    @RenderColumn(name = "已打印次数", sort = 7, isToDoList = true )
    private Integer printCount;

    @RenderColumn(name = "上次打印人", sort = 8, isToDoList = true )
    private String lastPrinterName;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date lastPrintTime;

    @RenderColumn(name = "上次打印时间", sort = 9, isToDoList = true )
    private String lastPrintTimeFormat;

    public String getLastPrintTimeFormat(){
        return DateHelper.dateFormat( lastPrintTime, DateHelper.YYYYMMDDHHMMSS );
    }

    @RenderColumn(name = "申请原因", sort = 10, isToDoList = true )
    private String reason;

    private String userId;

    private String printFlag;

    public String getPrintFlagText() {
        return CommonConst.TRUE.equals(printFlag) ? "已打印" : "未打印";
    }

    public String getShisBusinessId() {
        return id;
    }

    public String getShisBusinessNo() {
        return applyNo;
    }

    public String getShisBusinessType() {
        return BusinessType.DYSQ.getType();
    }

    public String getBillTypeName(){
        return BusinessType.DYSQ.getTypeName();
    }

}
